var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("TimeViewNode"),
    p = cc._decorator,
    l = p.ccclass,
    d = p.property,
    u =
        (p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.btnNode = null;
                e.norNode = null;
                e.foodNode = null;
                e.foodView = null;
                e.timeViewNode = null;
                return e;
            }
            e.prototype.onLoad = function () {
                EVUIEffView.on(EVUIEffView.checkView, this.checkView.bind(this), this);
                this.btnNode.active = !1;
                this.starCheckData();
            };
            e.prototype.onDestroy = function () {
                EVUIEffView.offTarget(this);
            };
            e.prototype.checkView = function () {
                var t = GameDataValue.getHotTime();
                if (t) {
                    this.norNode.active = !1;
                    var e = CacheDataManager.teMaiTime;
                    this.foodNode.active = !0;
                    SpriteView.setFoodSprite(this.foodView, t.foodId);
                    this.timeViewNode.checkView(t.time, e, this.moveTimeCall.bind(this));
                } else {
                    this.norNode.active = !0;
                    this.foodNode.active = !1;
                }
            };
            e.prototype.clickIndex = function () {
                GameDataValue.getHotTime() || s.default.open(r.UIID.UITeMai);
            };
            e.prototype.moveTimeCall = function (t) {
                if ("1" == t && GameDataValue.getHotTime()) {
                    GameDataValue.setHotData("");
                    this.checkViewAll();
                    this.starCheckData();
                    EVUIEffView.emit(EVUIEffView.checkView);
                }
            };
            e.prototype.starCheckData = function () {
                var t = this;
                if (GameDataValue.getLastLv() >= 4) {
                    this.checkViewAll();
                    this.checkView();
                    this.schedule(function () {
                        t.checkViewAll();
                    }, 5);
                } else this.btnNode.active = !1;
            };
            e.prototype.checkViewAll = function () {
                var t = GameDataValue.getLastHotTime();
                if (Date.now() - t < CacheDataManager.teMaiCdTime) this.btnNode.active = !1;
                else if (this.getFoodCount() >= 3) {
                    this.openGuild();
                    this.btnNode.active = !0;
                    this.node.stopAllActions();
                }
            };
            e.prototype.getFoodCount = function () {
                var t = 0,
                    e = CacheDataManager.getFoodLevelData();
                for (var o in e) e[o] >= 1 && t++;
                return t;
            };
            e.prototype.openGuild = function () {
                if (!GuildCache.isOverOnceGuid(GuildCache.oncecheckId[4][0])) {
                    GuildCache.checkKey = GuildCache.oncecheckId[4][0];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[4][0]);
                    GuildCache.openGuildView();
                }
            };
            n([d(cc.Node)], e.prototype, "btnNode", void 0);
            n([d(cc.Node)], e.prototype, "norNode", void 0);
            n([d(cc.Node)], e.prototype, "foodNode", void 0);
            n([d(cc.Sprite)], e.prototype, "foodView", void 0);
            n([d(c.default)], e.prototype, "timeViewNode", void 0);
            return n([l], e);
        })(cc.Component));
o.default = u;
